package syn;

import java.util.*;

public class TestList {
    public static void main(String[] args) throws InterruptedException {
        /*List<String> list = new ArrayList<>();

            for (int i = 0; i <10000; i++) {
                    new Thread(() -> {
                        synchronized (list) {
                            list.add(Thread.currentThread().getName());
                        }
                    }).start();
            }*/
        List<String> list = new Vector<>();
        for (int i = 0; i < 10000; i++) {
            new Thread(()->{
                list.add(Thread.currentThread().getName());
            }).start();
        }
            Thread.sleep(2000);
            System.out.println(list.size());

        }
    }
